function [h, total] = generateHist(img, K)
% GENERATEHIST
% Output :
%   H : Histogram, a 1*(2K+1) matrix.
%   TOTAL : Number of samples in range.
%
    u = [-K:1:K];
    h = histc(img(:)', u);
    total = sum(h);
    if total > 0
        h = h / total;
    end
end
